<template>
  <div class="support-index">
    <div class="demo-nav">
      <div class="demo-nav__title">没钱建房怎么办-平台为您解忧</div>
      <svg viewBox="0 0 1000 1000" class="demo-nav__back" @click="toBack">
        <path fill-rule="evenodd" fill="#969799" d="M296.114 508.035c-3.22-13.597.473-28.499 11.079-39.105l333.912-333.912c16.271-16.272 42.653-16.272 58.925 0s16.272 42.654 0 58.926L395.504 498.47l304.574 304.574c16.272 16.272 16.272 42.654 0 58.926s-42.654 16.272-58.926 0L307.241 528.058a41.472 41.472 0 0 1-11.127-20.023z"></path>
      </svg>
    </div>
    <div class="support-index-header">
      <div class="support-index-h-top">
        <h2 style="font-size: 1.5rem">没钱建房怎么办?</h2>
        <h3 style="padding: 0.5rem 0">平台为您解忧</h3>
      </div>
      <div class="support-index-h-bottom">
        <p>最高借贷额度</p>
        <p style="margin: 0.5rem 0;font-size: 2rem">200000</p>
        <van-button round type="primary" @click="biaodan" style="width: 15rem">马上咨询</van-button>
      </div>
    </div>
    <div class="support-index-brand">
      <p style="text-align: left;padding: 1rem;font-size: 0.95rem;font-weight: bolder">合作品牌</p>
      <div class="person-div">
        <van-swipe @change="onChange"  class="my-swipe" :autoplay="3000" indicator-color="white" >
          <van-swipe-item v-for="item in CooperativeBrandList">
            <van-image width="100%" height="100%" fit="cover" :src="item.cooperativeUrl"/>
          </van-swipe-item>
          <template #indicator>
            <div class="custom-indicator">{{ current + 1 }}/{{CooperativeBrandList.length}}</div>
          </template>
        </van-swipe>
        <!--<ul class="person-list" ref="personTab">-->
          <!--<li class="person-item" >-->
            <!--<span v-for="a in indexaa">-->
                <!--<van-image-->
                  <!--width="12rem"-->
                  <!--height="11rem"-->
                  <!--fit="contain"-->
                  <!--style="display: inline-block;padding: 0 5px"-->
                  <!--src="https://img.yzcdn.cn/vant/cat.jpeg"-->
                <!--/>-->
            <!--</span>-->
          <!--</li>-->
        <!--</ul>-->
      </div>
    </div>
    <div class="support-index-process">
      <p style="text-align: left;font-size: 0.95rem;font-weight: bolder">
        申请全流程<span style="color: #ebedf0;font-size: 0.95rem"> APPLICATION PROCESS</span>
      </p>
      <van-icon name="stop" size="1.5rem" style="position: absolute;top: 0.9rem;right: 0.55rem"/>
      <div class="support-index-pro" style="text-align: left;margin-top: 0.5rem">
        <van-steps direction="vertical" inactive-icon="checked" inactive-color="#07c160" active="active" color="#ff8917">
          <van-step>
            <div class="support-index-pros">
              <div class="support-index-pros1">
                <p>{{ProductFlowList.textOne}}</p>
              </div>
              <div class="support-index-pros2">
                <p style="font-size: 0.9rem;color: black">{{ProductFlowList.textTwo}}</p>
                <p style="font-size: 0.7rem">{{ProductFlowList.textThere}}</p>
              </div>
            </div>
          </van-step>
          <van-step>
            <div style="color: #07c160">
              {{ProductFlowList.oneTime}}
            </div>
          </van-step>
          <van-step>
            <div class="support-index-pros">
              <div class="support-index-pros1">
                <p>{{ProductFlowList.textFour}}</p>

              </div>
              <div class="support-index-pros2">
                <p style="font-size: 0.9rem;color: black">{{ProductFlowList.textFive}}</p>
                <p style="font-size: 0.7rem">{{ProductFlowList.textSix}}</p>
              </div>
            </div>
          </van-step>
          <van-step>
            <div style="color: #07c160 ">
              {{ProductFlowList.twoTime}}
            </div>
          </van-step>
          <van-step>
            <div class="support-index-pros">
              <div class="support-index-pros1">
                <p>{{ProductFlowList.textSeven}}</p>
              </div>
              <div class="support-index-pros2">
                <p style="font-size: 0.9rem;color: black">{{ProductFlowList.textEight}}</p>
                <p style="font-size: 0.7rem">{{ProductFlowList.textNine}}</p>
              </div>
            </div>
          </van-step>
        </van-steps>
      </div>
    </div>
    <div class="support-index-advantage">
      <p style="text-align: left;font-size: 0.95rem;font-weight: bolder">
<!--        产品优势<span style="color: #ebedf0;font-size: 0.95rem"> PRODUCT SUPERIORITY</span>-->
      </p>
      <van-icon name="stop" size="1.5rem" style="position: absolute;top: 1rem;right: 0.55rem"/>
      <div style="margin-top: 0.6rem" v-for="item in ProductSuperiorityList">
        <van-image width="10rem" height="10rem" fit="cover" :src="item.superiorityUrl"/>
      </div>
    </div>

<!--    <van-button @click="sharea">微信分享</van-button>-->
<!--    <van-button @click="shareer">微信分享二</van-button>-->
<!--    <van-button @click="sharesan">微信分享三</van-button>-->
<!--    <van-button @click="sharesisss">微信分享四</van-button>-->

    <van-popup v-model="show" style="width: 18rem;height: 30rem" @submit="onSubmit">

      <van-form ref="form" :model="form" >
        <van-field
          v-model="form.borrowQian"
          name="借款金额"
          label="借款金额"
          placeholder="借款金额"
          :rules="[{ required: true, message: '请填写借款金额' }]"
        />

<!--        <van-field-->
<!--          v-model="form.customerId"-->
<!--          name="借款金额"-->
<!--          label="借款金额"-->
<!--          placeholder="借款金额"-->
<!--        />-->



        <van-field
          v-model="form.name"
          name="姓名"
          label="姓名"
          placeholder="姓名"
          :rules="[{ required: true, message: '请填写用户名' }]"
        />
        <van-field
          v-model="form.identity"
          name="身份证号"
          label="身份证号"
          placeholder="身份证号"
          :rules="[{ required: true, message: '请填写用户名' }]"
        />
        <van-uploader
          upload-text="身份证正面"
          v-model="identityZheng"
          :deletable="false"
          :max-count="1"
          :after-read="firstRead"
        />
        <van-uploader
          upload-text="身份证背面"
          v-model="identityBei"
          :deletable="false"
          :max-count="1"
          :after-read="lastRead"
        />

        <van-field
          v-model="form.address"
          name="家庭住址"
          label="家庭住址"
          placeholder="家庭住址"
          :rules="[{ required: true, message: '请填写家庭住址' }]"
        />
        <van-field
          v-model="form.purpose"
          name="借钱用途"
          label="借钱用途"
          placeholder="借钱用途"
          :rules="[{ required: true, message: '请填写借钱用途' }]"
        />
        <van-field
          v-model="form.sex"
          name="性别"
          label="性别"
          placeholder="性别"
          :rules="[{ required: true, message: '请选择性别' }]"
        >
          <template #input>
            <van-radio-group v-model="form.sex" direction="horizontal">
              <van-radio name="0">男</van-radio>
              <van-radio name="1">女</van-radio>
            </van-radio-group>
          </template>
        </van-field>

        <van-field
          v-model="form.lifeLoan"
          name="借款期限"
          label="借款期限(月)"
          placeholder="借款期限"
          :rules="[{ required: true, message: '请填写借款期限(月)' }]"
        />


        <div style="margin: 16px;">
          <van-button round block type="info" @click="submitForm">提交</van-button>
        </div>
      </van-form>

    </van-popup>

  </div>
</template>

<script>
  import { moneyuploadVoucher } from "@/api/moneyen";
  import { moneyadd } from "@/api/moneyen";
  import BScroll from 'better-scroll' //导入better-scroll
  import {
    selectCooperativeBrandByNull,
    selectProductSuperiorityByNull,
    getProductFlow,
    getTextPay
  } from '@/api/financialSupport/financial_support.js'
  import { Toast } from "vant";
  import { getSignature } from "@/api/commodity/alipay";
  export default {
    name: "support_index",
    data() {
      return {
        identityZheng: [],
        identityBei: [],
        form:{
          identityZheng: '',
          identityBei: '',
        },
        show: false,
        active: [5],
        //合作伙伴集合
        CooperativeBrandList:[],
        //产品优势集合
        ProductSuperiorityList:[],
        current: 0,
        //申请流程集合
        ProductFlowList:[
          {
            textOne:null,
            textTwo:null,
            textThere:null,
            textFour:null,
            textFive:null,
            textSix:null,
            textSeven:null,
            textEight:null,
            textNine:null,
            oneTime:null,
            twoTime:null
          }
        ],
      };
    },
    //页面渲染前加载
    created(){
      this.getselectCooperativeBrandByNull();
      this.getselectProductSuperiorityByNull();
      this.getProductFlowByNull();
    },
    //方法
    methods: {
      onSubmit(){

      },

      firstRead(e) {
        //注意，我们这里没有使用form表单提交文件，所以需要用new FormData来进行提交
        let fd = new FormData()
        fd.append("file", e.file)
        moneyuploadVoucher(fd).then(res => {
          this.form.identityZheng = "http://51jhf.com/profile/xiazai"+res.data.tu;
          if (res.data.code == 200) {
            Toast({
              message: "上传成功。",
              position: "top"
            });
          } else {
            // alert('第一期支付凭证上传失败，请重试！')
          }

        });
      },
      lastRead(e) {
        //注意，我们这里没有使用form表单提交文件，所以需要用new FormData来进行提交
        let fd = new FormData()
        fd.append("file", e.file)
        moneyuploadVoucher(fd).then(res => {
          this.form.identityBei = "http://51jhf.com/profile/xiazai"+res.data.tu;
          if (res.data.code == 200) {
            Toast({
              message: "上传成功。",
              position: "top"
            });
          } else {
            // alert('第一期支付凭证上传失败，请重试！')
          }

        });
      },


      biaodan(){
        this.show = true;
      },
      submitForm(){
        moneyadd(this.form).then(res=>{
          Toast.success('申请成功,后台正在审核');
          this.show = false;
        })
      },


      toBack(){
        this.$router.go(-1);//返回上一层
      },
      //查询全部的合作伙伴
      getselectCooperativeBrandByNull(){
        selectCooperativeBrandByNull().then((res)=>{
          this.CooperativeBrandList = res.data.data;
        })
      },
      //查询申请流程
      getProductFlowByNull(){
        getProductFlow().then((res)=>{
          this.ProductFlowList = res.data.data;
          }
        )
      },
      //查询全部的产品优势
      getselectProductSuperiorityByNull(){
        selectProductSuperiorityByNull().then((res)=>{
          this.ProductSuperiorityList = res.data.data;
          console.log(res,"456");
        })
      },
      //轮播点击
      onChange(index) {
        this.current = index;
      },
    }
  }
</script>

<style scoped>
  .demo-nav{
    position: relative;
    display: flex;
    -webkit-box-align: center;
    align-items: center;
    -webkit-box-pack: center;
    justify-content: center;
    height: 56px;
    background-color: #fff;
    font-size: 1.1rem;
  }
  .demo-nav__back{
    position: absolute;
    top: 16px;
    left: 16px;
    width: 24px;
    height: 24px;
    cursor: pointer;
  }
  .support-index-header{
    background-color: #ebedf0;
    padding: 1rem;
  }
  .support-index-h-top{
    text-align: left;
  }
 .support-index-h-bottom{
   background-color: #ffffff;
   margin-top: 0.5rem;
   padding: 1rem 0;
  }
  .support-index-process{
    padding: 1rem;
    position: relative
  }
  .support-index-process .support-index-pros1{
    display: inline-block;
    background-color: #07c160;
    text-align:left;
    color: #ffffff;
    padding: 0.5rem 1rem;
    border-radius: 0.5rem;
  }
  .support-index-process .support-index-pros2{
    display: inline-block;
    text-align: left;
    padding-left: 0.5rem;
  }
  .support-index-advantage{
    padding: 1rem;
    position: relative
  }
  .person-div{
    margin-left: 15px;
    margin-right: 15px;
    overflow: auto;         /*核心样式*/
  }
  .person-list{
    white-space: nowrap;    /*核心样式*/
  }
  .person-item{
    width: 90%;
    height: auto;
    font-size: 14px;
    line-height: 44px;
    text-align: center;
    display: inline-block;  /*核心样式*/
    *zoom:1;
    *display:inline;
    vertical-align:top;
  }

  .custom-indicator {
    position: absolute;
    right: 5px;
    bottom: 5px;
    padding: 2px 5px;
    font-size: 12px;
    background: rgba(0, 0, 0, 0.1);
  }
  .my-swipe .van-swipe-item {
    color: #fff;
    font-size: 20px;
    line-height: 250px;
    text-align: center;
    background-color: #39a9ed;
  }


</style>
